package com.lxp.base.net.builder;

import android.text.TextUtils;

import com.lxp.base.net.self.BaseCallBack;
import com.lxp.base.net.self.IBaseHttp;

/**
 * Created by lxp on 2017/6/4.
 */

public class PostBuilder extends BaseParamBuilder<PostBuilder> {

    @Override
    public void send(BaseCallBack callBack) {
        try {
            if (TextUtils.isEmpty(mUrl)) {
                throw new IllegalArgumentException("url can not be null !");
            }
            if (null != mParams && !mParams.isEmpty()) {
                mHttp.appendParams(mParams);
            }
            if (null != mHeaders && !mHeaders.isEmpty()) {
                mHttp.appendHeaders(mHeaders);
            }
            mHttp.setUrl(mUrl)
                    .setTag(mTag)
                    .isCache(isCache, mCacheTime)
                    .post(callBack);
        } catch (Exception e) {
            callBack.isFail(e);
        }
    }

    public PostBuilder(IBaseHttp mHttp) {
        super(mHttp);
    }

}
